﻿//-----------------------------------------------------------------------
// <copyright file="Websites.cs" company="CMSN Software">
//    Copyright © 2010  CMSN Software
//    This program is free software: you can redistribute it and/or modify
//    it under the terms of the GNU General Public License as published by
//    the Free Software Foundation, either version 3 of the License, or
//    (at your option) any later version.
//
//    This program is distributed in the hope that it will be useful,
//    but WITHOUT ANY WARRANTY; without even the implied warranty of
//    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//    GNU General Public License for more details.
//
//    You should have received a copy of the GNU General Public License
//    along with this program.  If not, see http://www.gnu.org/licenses.
// </copyright>
//-----------------------------------------------------------------------

namespace JavaScriptSample
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    /// <summary>
    /// website details
    /// </summary>
    public struct Websites
    {
        /// <summary>
        /// Gets or sets the title.
        /// </summary>
        /// <value>
        /// The title.
        /// </value>
        public string Title { get; set; }

        /// <summary>
        /// Gets or sets the navigation URL.
        /// </summary>
        /// <value>
        /// The navigation URL.
        /// </value>
        public string NavigationLink { get; set; }

        /// <summary>
        /// Implements the operator ==.
        /// </summary>
        /// <param name="websites1">The websites1.</param>
        /// <param name="websites2">The websites2.</param>
        /// <returns>
        /// The result of the operator.
        /// </returns>
        public static bool operator ==(Websites websites1, Websites websites2)
        {
            return websites1.Equals(websites2);
        }

        /// <summary>
        /// Implements the operator !=.
        /// </summary>
        /// <param name="websites1">The websites1.</param>
        /// <param name="websites2">The websites2.</param>
        /// <returns>
        /// The result of the operator.
        /// </returns>
        public static bool operator !=(Websites websites1, Websites websites2)
        {
            return !websites1.Equals(websites2);
        }

        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
        /// </returns>
        public override int GetHashCode()
        {
            return this.Title.GetHashCode() ^ this.NavigationLink.GetHashCode();
        }

        /// <summary>
        /// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
        /// </summary>
        /// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
        /// <returns>
        ///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (!(obj is Websites))
            {
                return false;
            }

            return this.Equals((Websites)obj);
        }

        /// <summary>
        /// Equals the specified other.
        /// </summary>
        /// <param name="other">The other.</param>
        /// <returns>Boolean value</returns>
        public bool Equals(Websites other)
        {
            if (this.Title != other.Title)
            {
                return false;
            }

            return this.NavigationLink == other.NavigationLink;
        }
    }
}
